package com.yue.procress;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yue.bean.json.User;

import java.io.CharArrayWriter;
import java.io.File;
import java.io.IOException;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/10/8<br/>
 *
 * @author QiuYang
 */
public class FullBind {
    public static void main(String[] args) {

        ObjectMapper mapper = new ObjectMapper();
        try {
            User user = mapper.readValue(FullBind.class.getClassLoader().getResourceAsStream("user.json"), User.class);

            System.out.println(user.getName().getFirst() + "-" + user.getName().getLast());
            System.out.println(user.getGender().name());
            System.out.println(user.isVerified());
            System.out.println(String.valueOf(user.getUserImage()));

            CharArrayWriter writer = new CharArrayWriter();
            mapper.writeValue(writer, user);

            System.out.println(writer);

//            char[] buffer = new char[1024];
//            writer.write(buffer);
//            System.out.println(String.valueOf(buffer));

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
